home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-25 | 2.4 KB | 118 lines | [TEXT/CWIE] |
- /*
- File: MoreDialogs.cp
-
- Contains:
-
- Written by: Pete Gontier (PCG)
-
- Copyright: Copyright (c) 1998 Apple Computer, Inc.
-
- Change History (most recent first):
-
- <2> 7/24/98 PCG eliminate dependency on 'qd'
- <1> 6/16/98 PCG initial checkin
- */
-
- #include <Sound.h>
-
- #include "MoreDialogs.h"
-
- pascal void SaferShortenDITL (DialogPtr dialog, DialogItemIndex index)
- {
- while (index--) ShortenDITL (dialog, 1);
- }
-
- pascal DialogPtr MoreGetNewDialog (short dlogResID)
- {
- return GetNewDialog (dlogResID, nil, kFirstWindowOfClass);
- }
-
- pascal void SetDialogItemString (DialogPtr dialog, DialogItemIndex index, ConstStr255Param str)
- {
- if (MoreAssert (dialog && index))
- {
- short iType; Rect iRect; Handle iHandle;
- GetDialogItem (dialog,index,&iType,&iHandle,&iRect);
- SetDialogItemText (iHandle, str ? str : "\p");
- }
- }
-
- pascal void GetDialogItemString (DialogPtr dialog, DialogItemIndex index, StringPtr str)
- {
- if (MoreAssert (dialog && index && str))
- {
- short iType; Rect iRect; Handle iHandle;
- GetDialogItem (dialog,index,&iType,&iHandle,&iRect);
- GetDialogItemText (iHandle, str);
- }
- }
-
- pascal void SelectAllDialogItemText (DialogPtr dialog, DialogItemIndex index)
- {
- SelectDialogItemText (dialog,index,0,32767);
- }
-
- pascal void MoveableModalDialog (ModalFilterUPP mfp, short *itemHit)
- {
- //
- // I just made this logic up.
- // In a perfect world, I would steal the implementation
- // of the real ModalDialog and tweak it a little bit.
- // Consider it a to-do item.
- //
-
- EventRecord event;
- DialogRef pop, dummy;
- WindowRef whichWindow;
- short partCode;
- Boolean handledIt = false;
-
- pop = FrontWindow( );
- *itemHit = kDialogItemIndexNone;
-
- do
- {
- WaitNextEvent (everyEvent & ~highLevelEventMask, &event, GetCaretTime( ), nil);
-
- switch (event.what)
- {
- case mouseDown:
-
- partCode = FindWindow (event.where, &whichWindow);
-
- if (whichWindow != pop)
- {
- if (partCode == inSysWindow)
- SystemClick (&event,whichWindow);
- else
- SysBeep(10);
- break;
- }
-
- if (inDrag == partCode)
- {
- Rect dragBounds;
-
-
- dragBounds = (**GetMainDevice ( )).gdRect;
- InsetRect (&dragBounds, 4, 4);
- DragWindow (pop, event.where, &dragBounds);
- break;
- }
-
- // fall thru
-
- default:
-
- if (mfp)
- handledIt = CallModalFilterProc (mfp,pop,&event,itemHit);
-
- if (!handledIt && IsDialogEvent(&event))
- DialogSelect(&event,&dummy,itemHit);
-
- break;
- }
- }
- while (*itemHit == kDialogItemIndexNone);
- }
-